package ObjGitService

import (
	"arabApi/app/api/models/ObjGitModel"
	"arabApi/app/api/requests/ObjGitRequest"
	"github.com/spf13/cast"
	"time"
)

func BranchList(r ObjGitRequest.GitBranch) ([]ObjGitModel.TpGitBranch, int64) {
	return ObjGitModel.BranchList(r)
}

func BranchAdd(r ObjGitRequest.GitBranch) (uint64, error) {
	r.Step = 0
	r.Branch = cast.ToString(time.Now().Unix())

	return ObjGitModel.BranchAdd(r)
}
func BranchEdit(r ObjGitRequest.GitBranch) error {
	return ObjGitModel.BranchEdit(r)
}

func BranchMsgByID(r string) ObjGitModel.TpGitBranch {
	id := cast.ToInt64(r)
	return ObjGitModel.BranchMsgByid(id)
}

func BranchMsgByStep(r uint64) []ObjGitModel.TpGitBranch {
	return ObjGitModel.BranchMsgByStep(cast.ToInt64(r))
}

func EditBranchStep(id string, step int) error {
	return ObjGitModel.EditBranchStep(cast.ToInt(id), step)
}

func EditBranchMsg(id, msg string) error {
	return ObjGitModel.EditBranchMsg(cast.ToInt(id), msg)
}
